
inherit WWW_BASE;

#define WIDTH 555

private string get_content( string, mapping args, class http_request req );

void setup() {
    set_title("Connecting to "+mud_name() );
    set_content( (: get_content :) );
} /* setup() */

/** @ignore yes */
private string get_content( string, mapping args, class http_request req ) {
    string host;
    int port;

    if( !mapp(args) || !args["width"] && !args["height"] && !args["help"] )
        return font()+"<h3>How To Connect To "+mud_name()+"</h3>\n"
            "<p>The address of "+mud_name()+" for connecting with a "
            "<a href=\"http://www.zuggsoft.com/zmud/zmudinfo.htm\" "
            "target=\"new\">mud client</a> is "+query_host_name()+", port "+
            __PORT__+".<br>\n"
            "Alternatively, you can connect with "
            "<a href=\"telnet://"+query_host_name()+":"+__PORT__+"\">telnet</a>, "
            "or use our <a href=\"connect.c?width="+WIDTH+"&height=420\">"
            "online Java Telnet Client</a>.<br><br><font size=\"1\">\n"
            "If you have trouble connecting with the Java Telnet Client, and "
            "you are sure it is not because of a firewall or something similar, "
            "please send us a <a href=\"mailto:"+webmaster()+"\">mail</a>, "
            "and we will try to fix it.</font></p>\n"
            "</font>\n";

    if( args["help"] )
        return font()+"<h3>A Simple MUD Client v1.0</h3>\n"
            "<h3>What it is</h3>\n"
            "<p>This is a small telnet client, that can be used to connect "
            "to a MUD. It understands ANSI colour and it has a 500 line "
            "scrollback buffer. You can scroll through it with "
            "PageUp/PageDown, or with the mouse.</p>\n"
            "<p>Unlike the other ANSI applets I've seen, it also has a "
            "separate input line, so the text you type doesn't get mixed up "
            "with incoming text from the MUD. The command line has a history "
            "buffer, and remembers the last 32 commands entered. Use the up "
            "and down arrows to scroll through the remembered commands.</p>\n"
            "<p>Note that, to make the most out of this limited buffer, "
            "commands entered more than once are only stored once in the "
            "history buffer. E.g., if you enter the sequence of commands "
            "\"inventory\", \"look\", \"consider all\", and again \"look\", "
            "the first instance of \"look\" will be erased, to conserve "
            "buffer space. I.e., the history buffer will now look like: "
            "\"inventory\", \"consider all\" and \"look\". To put it "
            "otherwise, it tries to remember up to 32 _different_ commands, "
            "which hopefully should be more useful than if 20 of them were "
            "duplicates.</p>\n"
            "<p>Also, being specially designed for MUD's, the keypad acts as "
            "a direction pad. E.g., you can press '7' on the keypad and have "
            "'nw' sent to the MUD. It really makes walking around faster and "
            "easier (you must have NumLock ON for this to work).</p>\n"
            "<p>The function keys also produce some useful commands, although "
            "if you're not on Discworld or a derivative thereof, they may "
            "not match the commands understood by the MUD, and thus will be "
            "less useful. In a future release, I might make the program load "
            "the commands from a text file.</p>\n"
            "<p>Due to popular request it now wraps incoming text, and it "
            "does it by breaking the line at a space character. It turned "
            "out that you can't reliably expect the MUD to always do the "
            "wrapping for you. Note that, due to speed reasons, it only "
            "wraps incoming text, not lines of text already received. I.e., "
            "if you resize the screen or change the font size, the already "
            "received text isn't re-formatted to the new width, but any text "
            "you receive from now on is.</p>\n"
            "<h3>What it isn't</h3>\n"
            "<p>Briefly, it isn't a general purpose terminal emulation. It "
            "understands the ANSI colour codes, and the ANSI bright and "
            "reverse video commands. But that's all. It does NOT understand "
            "the cursor positioning commands, nor underline, nor italic, nor "
            "the rest of the ANSI standard, at least not for now.</p>\n"
            "<p>I.e., it should be ideal for connecting to most MUD's, but "
            "not for playing a telnet version of space invaders, because it "
            "lacks cursor positioning.</p>\n"
            "<p>Also, it doesn't have local scripting, aliases, timers or "
            "triggers. At least, not for now. Those would significantly "
            "inflate the size and number of classes downloaded, when used as "
            "an applet. I.e., it would make the applet load a whole lot "
            "slower. If you really need those, grab a copy of zMud or gMud "
            "instead.</p>\n"
            "<h3>The Buttons</h3>\n"
            "<dl>\n"
            "<dt><strong>Disconnect</strong>\n"
            "<dd>\n"
            "Disconnects you from the MUD. Note that this will make you "
            "net-dead, instead of properly logging you out, so it's "
            "generally bad practice.\n"
            "<dt><strong>Connect</strong>\n"
            "<dd>\n"
            "Connects you to the MUD. If you were connected already, it "
            "first disconnects you, and then connects again.\n"
            "<dt><strong>Large Font</strong>\n"
            "<dd>\n"
            "Use 14 pixel bold Courier for a font. You'll appreciate this "
            "if you're using very high resolution, like I do :) If your MUD "
            "auto-detects screen size, but it is NOT fully compliant with "
            "RFC 1073, you may need to reconnect to force it to notice the "
            "new screen size.\n"
            "<dt><strong>Small Font</strong>\n"
            "<dd>\n"
            "Use 12 pixel plain Courier for a font. Mainly there for those "
            "of you with 640x480 screens. If your MUD auto-detects screen "
            "size, but it is NOT fully compliant with RFC 1073, you may need "
            "to reconnect to force it to notice the new screen size.\n"
            "<dt><strong>Detach</strong>\n"
            "<dd>\n"
            "If it's used as an applet, detaches it from the html page and "
            "into a separate frame. I.e., now you can resize it freely, to "
            "suit your preferences. This button will only be visible if it's "
            "run as an applet, and it isn't detached already.\n"
            "<dt><strong>Attach</strong>\n"
            "<dd>\n"
            "Nukes the frame, and attaches the client back onto the html "
            "page. This button will only be visible if it's run as an "
            "applet, and it is currently detached.\n"
            "</dl>\n"
            "<h3>Hints</h3>"
            "<p>On Discworld or derivatives, use 'term network'. This will "
            "enable negotiating window size on the fly. I.e., when you "
            "change the window size or font size, the mud will automatically "
            "adjust its text wrapping and pausing.</p>\n"
            "<h3>Compatibility Considerations</h3>"
            "<p>The applet uses the 1.1 AWT event model, as opposed to the "
            "more simplistic 1.02. I.e., you'll need a browser that does "
            "understand Java 1.1 to use it as an applet, or a 1.1 or 1.2 "
            "compatible JDK or JRE to run it as a standalone application."
            "</p>\n"
            "<p>It has been extensively tested as an applet with Netscape "
            "4.51 and 4.6, and Internet Explorer 5.0. As an application it "
            "has been tested with Sun's JDK 1.2.1 with the HotSpot JVM, "
            "IBM's 1.1.7 JRE, and Microsoft's Virtual Machine build 3167 and "
            "3177.</p>\n"
            "<p>If you have Netscape Navigator 4.05 or earlier, it has a "
            "problem with understanding the 1.1 AWT event model. Allegedly, "
            "there is a patch for that. Or you can just get a newer version "
            "of Netscape.</p>\n"
            "<p>Also, I would recommend NOT using Internet Explorer or the "
            "Microsoft JVM to run it. They are buggy and slightly "
            "incompatible with the standard. Note that I'm not preaching "
            "anti-Microsoft theory, but it's based on actual testing. E.g., "
            "under my current Microsoft JVM, it doesn't seem to notice the "
            "PageUp and PageDown keys, so you're stuck with using a mouse to "
            "scroll back. Also, it doesn't seem to allow using ALT and the "
            "keypad to enter extended characters. Unless you enjoy wanton "
            "incompatibilities and headaches, avoid Microsoft's Java "
            "implementations. This may change in time though.</p>\n"
            "<hr align=\"left\" size=\"1\">\n"
            "<center><font size=\"-1\">Copyright &copy; 1999 JagdTiger."
            "</font></center>\n";

    host = HTTP_H->query_server_ip();

    if( host == query_host_name() || host[0..9] == "192.168.0." ||
        host == "127.0.0.1")
        if( sscanf( req->hostname, "%s:%d", host, port ) != 2 || host == "")
            host = req->hostname;

    return "<center>"+font()+"<!-- Here begins the applet code. -->\n"
        "<applet archive=\"java/classes.zip\" code=\"ANSI_Client.class\" "
        "width=\""+args["width"]+"\" height=\""+args["height"]+"\" "
        "vspace=\"2\">\n"
        "  <param name=\"applet\"     value=\"telnet\">\n"
        "  <param name=\"host\"       value=\""+host+"\">\n"
        "  <param name=\"port\"       value=\""+__PORT__+"\">\n"
        "  <param name=\"buttons\"    value=\"Y\">\n"
        "  <b>Your Browser seems to have no "
        "<a href=\"http://java.sun.com/\">Java</a> support. "
        "Please get a new browser or enable Java to use this applet!</b>\n"
        "</applet><br>\n"
        "<a href=\"connect.c?help=me\" target=\"_new\">Help!</a><br>\n"
        "This applet was kindly supplied by JagdTiger.  Copyright &copy; 1999 "
        "JagdTiger.\n"
        "</font></center>\n";

} /* www_request() */
